/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.classicmodels.model;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author Chona
 */
public class Datasource {
    private static Connection connection;
    
    public static Connection getConnection() throws Exception{
       if (connection==null)
       {
           connection= conectarBaseDeDatos();
       }
        return connection;
    }
    
    private static final String CONNECTION_STRING= "jdbc:mysql://localhost/classic_models_inc";
    private static final String USUARIO= "root";
    private static final String PASSWORD= "root";
    
   // se conecta a la base de datos y me devuelve la coneccion
    public static Connection conectarBaseDeDatos() throws Exception{
       
            Class.forName("com.mysql.jdbc.Driver");
            Connection c =DriverManager.getConnection(CONNECTION_STRING,USUARIO,PASSWORD);
            return  c;
    }
}
